package es.juanc.formatter;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;

public class NumberFormatTest { 
	  
	public static String formateador( BigDecimal number ) {		
		
	    NumberFormat nf = NumberFormat.getInstance(new Locale("es"));	
	    nf.setMaximumFractionDigits( 7 );	
	    nf.setMinimumFractionDigits( 0 );
	    nf.setMinimumIntegerDigits( 1 );
	    //DecimalFormat df = new DecimalFormat();
		return nf.format( number );
	}
	
	public static void main (String[] args) throws Exception { 
		
//	    NumberFormat nf = NumberFormat.getInstance();	    
//	    BigDecimal bd = new BigDecimal(1234.56);	    
//	    System.out.println( "Double value = \t\t" + bd.doubleValue() );
//	    System.out.println( "toString() = \t\t" + bd.toString() );
//	    System.out.println( "toPlainString() = \t" + bd.toPlainString() );
//	    System.out.println( "Number format = \t" + nf.format( bd ) );

		System.out.println( "111129.03251239 -> " + formateador( new BigDecimal("111129.0325123") ) );
		System.out.println( "129.03251239 -> " + formateador( new BigDecimal("129.0325123") ) );
		System.out.println( "129.0325123 -> " + formateador( new BigDecimal("129.0325123") ) );
		System.out.println( "129.03250000 -> " + formateador( new BigDecimal("129.0325000") ) );
		System.out.println( "129.00000000 -> " + formateador( new BigDecimal("129.0000000") ) );
		System.out.println( "0.8500000 -> " + formateador( new BigDecimal("0.8500000") ) );	
		System.out.println( "0.0000000 -> " + formateador( new BigDecimal("0.0000000") ) );	
	}
}